
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 04/05/2013 22:32:40
-- Generated from EDMX file: C:\TFS Projects\squadwuschel\MVC\ContactMvc4TB\EFDataModel\EFModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [ef];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_EFUserUserCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFUser] DROP CONSTRAINT [FK_EFUserUserCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_UserGroupEFUser_UserGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserGroupEFUser] DROP CONSTRAINT [FK_UserGroupEFUser_UserGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_UserGroupEFUser_EFUser]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserGroupEFUser] DROP CONSTRAINT [FK_UserGroupEFUser_EFUser];
GO
IF OBJECT_ID(N'[dbo].[FK_EFUserUserRight_EFUser]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFUserUserRight] DROP CONSTRAINT [FK_EFUserUserRight_EFUser];
GO
IF OBJECT_ID(N'[dbo].[FK_EFUserUserRight_UserRight]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFUserUserRight] DROP CONSTRAINT [FK_EFUserUserRight_UserRight];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRightUserGroup_UserRight]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRightUserGroup] DROP CONSTRAINT [FK_UserRightUserGroup_UserRight];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRightUserGroup_UserGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRightUserGroup] DROP CONSTRAINT [FK_UserRightUserGroup_UserGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_EFBaseEFPerson]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge] DROP CONSTRAINT [FK_EFBaseEFPerson];
GO
IF OBJECT_ID(N'[dbo].[FK_EFPersonUserTitle]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFPerson] DROP CONSTRAINT [FK_EFPersonUserTitle];
GO
IF OBJECT_ID(N'[dbo].[FK_EFPersonEFAddress]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFAddress] DROP CONSTRAINT [FK_EFPersonEFAddress];
GO
IF OBJECT_ID(N'[dbo].[FK_EFBaseEFPerson_Editor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge] DROP CONSTRAINT [FK_EFBaseEFPerson_Editor];
GO
IF OBJECT_ID(N'[dbo].[FK_EFAddressEFCountry]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFAddress] DROP CONSTRAINT [FK_EFAddressEFCountry];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataEFDynamicDataType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataMenge] DROP CONSTRAINT [FK_EFDynamicDataEFDynamicDataType];
GO
IF OBJECT_ID(N'[dbo].[FK_EFPersonEFDynamicDataTypeCreator]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeMenge] DROP CONSTRAINT [FK_EFPersonEFDynamicDataTypeCreator];
GO
IF OBJECT_ID(N'[dbo].[FK_EFBaseEFDynamicData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataMenge] DROP CONSTRAINT [FK_EFBaseEFDynamicData];
GO
IF OBJECT_ID(N'[dbo].[FK_DynamicDataTypeCategoryEFDynamicDataType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeMenge] DROP CONSTRAINT [FK_DynamicDataTypeCategoryEFDynamicDataType];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataTypeDynamicDataTypeListEntry]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DynamicDataTypeListEntryMenge] DROP CONSTRAINT [FK_EFDynamicDataTypeDynamicDataTypeListEntry];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataTypeUserGroupREAD_EFDynamicDataType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupREAD] DROP CONSTRAINT [FK_EFDynamicDataTypeUserGroupREAD_EFDynamicDataType];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataTypeUserGroupREAD_UserGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupREAD] DROP CONSTRAINT [FK_EFDynamicDataTypeUserGroupREAD_UserGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataTypeUserGroupWRITE_EFDynamicDataType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE] DROP CONSTRAINT [FK_EFDynamicDataTypeUserGroupWRITE_EFDynamicDataType];
GO
IF OBJECT_ID(N'[dbo].[FK_EFDynamicDataTypeUserGroupWRITE_UserGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE] DROP CONSTRAINT [FK_EFDynamicDataTypeUserGroupWRITE_UserGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_HolidayDaysEFWorktimeSetting]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HolidayDaysSatz] DROP CONSTRAINT [FK_HolidayDaysEFWorktimeSetting];
GO
IF OBJECT_ID(N'[dbo].[FK_EFAuthenticationEFWorktimeSetting]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFWorktimeSettingSatz] DROP CONSTRAINT [FK_EFAuthenticationEFWorktimeSetting];
GO
IF OBJECT_ID(N'[dbo].[FK_EFAuthenticationEFWorktime]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFWorktimeSet] DROP CONSTRAINT [FK_EFAuthenticationEFWorktime];
GO
IF OBJECT_ID(N'[dbo].[FK_EFWorktimeEFWorktimeEntry]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry] DROP CONSTRAINT [FK_EFWorktimeEFWorktimeEntry];
GO
IF OBJECT_ID(N'[dbo].[FK_EFWorktimeEntryEFWorktimeProject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry] DROP CONSTRAINT [FK_EFWorktimeEntryEFWorktimeProject];
GO
IF OBJECT_ID(N'[dbo].[FK_EFWorktimeSettingEFWorktimeProject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFWorktimeProjectSet] DROP CONSTRAINT [FK_EFWorktimeSettingEFWorktimeProject];
GO
IF OBJECT_ID(N'[dbo].[FK_EFPerson_inherits_EFBase]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFPerson] DROP CONSTRAINT [FK_EFPerson_inherits_EFBase];
GO
IF OBJECT_ID(N'[dbo].[FK_EFAuthentication_inherits_EFPerson]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFAuthentication] DROP CONSTRAINT [FK_EFAuthentication_inherits_EFPerson];
GO
IF OBJECT_ID(N'[dbo].[FK_EFUser_inherits_EFAuthentication]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFUser] DROP CONSTRAINT [FK_EFUser_inherits_EFAuthentication];
GO
IF OBJECT_ID(N'[dbo].[FK_UserCategory_inherits_EFCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFCategoryMenge_UserCategory] DROP CONSTRAINT [FK_UserCategory_inherits_EFCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_UserGroup_inherits_EFCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFCategoryMenge_UserGroup] DROP CONSTRAINT [FK_UserGroup_inherits_EFCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRight_inherits_EFCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFCategoryMenge_UserRight] DROP CONSTRAINT [FK_UserRight_inherits_EFCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_UserTitle_inherits_EFCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFCategoryMenge_UserTitle] DROP CONSTRAINT [FK_UserTitle_inherits_EFCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_EFAddress_inherits_EFBase]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFAddress] DROP CONSTRAINT [FK_EFAddress_inherits_EFBase];
GO
IF OBJECT_ID(N'[dbo].[FK_DynamicDataTypeCategory_inherits_EFCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFCategoryMenge_DynamicDataTypeCategory] DROP CONSTRAINT [FK_DynamicDataTypeCategory_inherits_EFCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_EFWorktimeEntry_inherits_EFBase]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry] DROP CONSTRAINT [FK_EFWorktimeEntry_inherits_EFBase];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[EFBaseMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge];
GO
IF OBJECT_ID(N'[dbo].[EFCountryMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCountryMenge];
GO
IF OBJECT_ID(N'[dbo].[EFDynamicDataTypeMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFDynamicDataTypeMenge];
GO
IF OBJECT_ID(N'[dbo].[EFDynamicDataMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFDynamicDataMenge];
GO
IF OBJECT_ID(N'[dbo].[DynamicDataTypeListEntryMenge]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DynamicDataTypeListEntryMenge];
GO
IF OBJECT_ID(N'[dbo].[EFWorktimeSettingSatz]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFWorktimeSettingSatz];
GO
IF OBJECT_ID(N'[dbo].[HolidayDaysSatz]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HolidayDaysSatz];
GO
IF OBJECT_ID(N'[dbo].[EFWorktimeSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFWorktimeSet];
GO
IF OBJECT_ID(N'[dbo].[EFWorktimeProjectSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFWorktimeProjectSet];
GO
IF OBJECT_ID(N'[dbo].[EFBaseMenge_EFPerson]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge_EFPerson];
GO
IF OBJECT_ID(N'[dbo].[EFBaseMenge_EFAuthentication]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge_EFAuthentication];
GO
IF OBJECT_ID(N'[dbo].[EFBaseMenge_EFUser]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge_EFUser];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge_UserCategory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge_UserCategory];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge_UserGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge_UserGroup];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge_UserRight]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge_UserRight];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge_UserTitle]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge_UserTitle];
GO
IF OBJECT_ID(N'[dbo].[EFBaseMenge_EFAddress]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge_EFAddress];
GO
IF OBJECT_ID(N'[dbo].[EFCategoryMenge_DynamicDataTypeCategory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFCategoryMenge_DynamicDataTypeCategory];
GO
IF OBJECT_ID(N'[dbo].[EFBaseMenge_EFWorktimeEntry]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFBaseMenge_EFWorktimeEntry];
GO
IF OBJECT_ID(N'[dbo].[UserGroupEFUser]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserGroupEFUser];
GO
IF OBJECT_ID(N'[dbo].[EFUserUserRight]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFUserUserRight];
GO
IF OBJECT_ID(N'[dbo].[UserRightUserGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserRightUserGroup];
GO
IF OBJECT_ID(N'[dbo].[EFDynamicDataTypeUserGroupREAD]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFDynamicDataTypeUserGroupREAD];
GO
IF OBJECT_ID(N'[dbo].[EFDynamicDataTypeUserGroupWRITE]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'EFBaseMenge'
CREATE TABLE [dbo].[EFBaseMenge] (
    [ID] bigint IDENTITY(1,1) NOT NULL,
    [Module] int  NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [CreatorID] bigint  NULL,
    [EditDate] datetime  NOT NULL,
    [EditorID] bigint  NULL
);
GO

-- Creating table 'EFCategoryMenge'
CREATE TABLE [dbo].[EFCategoryMenge] (
    [ID] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [TypeId] int  NOT NULL,
    [IsSystem] bit  NOT NULL,
    [CategoryTypeId] int  NOT NULL,
    [SortId] int  NULL,
    [ModuleId] int  NULL
);
GO

-- Creating table 'EFCountryMenge'
CREATE TABLE [dbo].[EFCountryMenge] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'EFDynamicDataTypeMenge'
CREATE TABLE [dbo].[EFDynamicDataTypeMenge] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ModuleId] int  NOT NULL,
    [DynamicDataTypeId] int  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [IsVisible] bit  NOT NULL,
    [SortId] nvarchar(max)  NOT NULL,
    [IsSystem] bit  NOT NULL,
    [RegExString] nvarchar(max)  NOT NULL,
    [CreationDate] datetime  NOT NULL,
    [CreatorID] bigint  NOT NULL,
    [IsRequired] bit  NOT NULL,
    [FormatString] nvarchar(max)  NULL,
    [Description] nvarchar(max)  NULL,
    [MaxLength] int  NULL,
    [CustomCssClass] nvarchar(max)  NULL,
    [MinLength] int  NULL,
    [DynamicDataTypeCategoryID] bigint  NOT NULL,
    [IsFilterable] bit  NULL
);
GO

-- Creating table 'EFDynamicDataMenge'
CREATE TABLE [dbo].[EFDynamicDataMenge] (
    [ID] bigint IDENTITY(1,1) NOT NULL,
    [EFDynamicDataTypeID] int  NOT NULL,
    [StringValue] nvarchar(max)  NULL,
    [IntegerValue] int  NULL,
    [DatetimeValue] datetime  NULL,
    [DecimalValue] float  NULL,
    [EFBaseID] bigint  NOT NULL,
    [BooleanValue] bit  NULL
);
GO

-- Creating table 'DynamicDataTypeListEntryMenge'
CREATE TABLE [dbo].[DynamicDataTypeListEntryMenge] (
    [ID] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [SortId] nvarchar(max)  NULL,
    [EFDynamicDataTypeID] int  NOT NULL
);
GO

-- Creating table 'EFWorktimeSettingSatz'
CREATE TABLE [dbo].[EFWorktimeSettingSatz] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [WorkingHours] float  NOT NULL,
    [WorkingDays_Mon] bit  NOT NULL,
    [WorkingDays_Tue] bit  NOT NULL,
    [WorkingDays_Wed] bit  NOT NULL,
    [WorkingDays_Thu] bit  NOT NULL,
    [WorkingDays_Fri] bit  NOT NULL,
    [WorkingDays_Sat] bit  NOT NULL,
    [WorkingDays_Sun] bit  NOT NULL,
    [DefaultStartWorkingTime] datetime  NOT NULL,
    [DefaultEndWorkingTime] datetime  NOT NULL,
    [DefaultStartBreakTime] datetime  NOT NULL,
    [DefaultEndBreakTime] datetime  NOT NULL,
    [DefaultWorktimeDescription] nvarchar(max)  NOT NULL,
    [EmploymentStartDate] datetime  NOT NULL,
    [WorktimeListType] int  NOT NULL,
    [WorkingDaysChangedDate] datetime  NOT NULL,
    [EFAuthentication_ID] bigint  NOT NULL
);
GO

-- Creating table 'HolidayDaysSatz'
CREATE TABLE [dbo].[HolidayDaysSatz] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Year] int  NOT NULL,
    [Days] float  NOT NULL,
    [EFWorktimeSetting_ID] int  NOT NULL
);
GO

-- Creating table 'EFWorktimeSet'
CREATE TABLE [dbo].[EFWorktimeSet] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Worktime] int  NOT NULL,
    [Overtime] int  NOT NULL,
    [Breaktime] int  NOT NULL,
    [ManualOvertime] int  NOT NULL,
    [EntryDate] datetime  NOT NULL,
    [IsLegalHoliday] bit  NOT NULL,
    [Illness] int  NOT NULL,
    [Qualificationtime] int  NOT NULL,
    [Projecttime] int  NOT NULL,
    [Holidaytime] int  NOT NULL,
    [EFAuthenticationID] bigint  NOT NULL,
    [DailyWorktime] int  NOT NULL,
    [WorktimeDays] int  NOT NULL
);
GO

-- Creating table 'EFWorktimeProjectSet'
CREATE TABLE [dbo].[EFWorktimeProjectSet] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NULL,
    [Sortorder] nvarchar(max)  NULL,
    [ShowEntry] bit  NOT NULL,
    [EFWorktimeSettingID] int  NULL
);
GO

-- Creating table 'EFBaseMenge_EFPerson'
CREATE TABLE [dbo].[EFBaseMenge_EFPerson] (
    [Firstname] nvarchar(max)  NOT NULL,
    [Lastname] nvarchar(max)  NOT NULL,
    [Telephone] nvarchar(max)  NULL,
    [UserTitleID] bigint  NOT NULL,
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFBaseMenge_EFAuthentication'
CREATE TABLE [dbo].[EFBaseMenge_EFAuthentication] (
    [Password] nvarchar(max)  NOT NULL,
    [Logintries] int  NOT NULL,
    [LastLoginDate] datetime  NULL,
    [CurrentLoginDate] datetime  NULL,
    [LoginEmail] nvarchar(max)  NOT NULL,
    [IsActiveUser] bit  NOT NULL,
    [PasswordResetDate] datetime  NULL,
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFBaseMenge_EFUser'
CREATE TABLE [dbo].[EFBaseMenge_EFUser] (
    [Birthdate] datetime  NULL,
    [UserTypeId] int  NOT NULL,
    [UserCategoryID] bigint  NOT NULL,
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFCategoryMenge_UserCategory'
CREATE TABLE [dbo].[EFCategoryMenge_UserCategory] (
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFCategoryMenge_UserGroup'
CREATE TABLE [dbo].[EFCategoryMenge_UserGroup] (
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFCategoryMenge_UserRight'
CREATE TABLE [dbo].[EFCategoryMenge_UserRight] (
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFCategoryMenge_UserTitle'
CREATE TABLE [dbo].[EFCategoryMenge_UserTitle] (
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFBaseMenge_EFAddress'
CREATE TABLE [dbo].[EFBaseMenge_EFAddress] (
    [IsDefault] bit  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [HouseNumber] nvarchar(max)  NOT NULL,
    [EFPersonID] bigint  NOT NULL,
    [Zipcode] nvarchar(max)  NOT NULL,
    [EFStreetID] int  NOT NULL,
    [Street] nvarchar(max)  NOT NULL,
    [City] nvarchar(max)  NOT NULL,
    [EFCountryID] int  NULL,
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFCategoryMenge_DynamicDataTypeCategory'
CREATE TABLE [dbo].[EFCategoryMenge_DynamicDataTypeCategory] (
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'EFBaseMenge_EFWorktimeEntry'
CREATE TABLE [dbo].[EFBaseMenge_EFWorktimeEntry] (
    [WorkingtimeType] int  NOT NULL,
    [StartTime] datetime  NOT NULL,
    [EndTime] datetime  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Notice] nvarchar(max)  NOT NULL,
    [EFWorktimeId] bigint  NOT NULL,
    [TimeInMinutes] int  NOT NULL,
    [EFWorktimeProjectId] bigint  NULL,
    [ID] bigint  NOT NULL
);
GO

-- Creating table 'UserGroupEFUser'
CREATE TABLE [dbo].[UserGroupEFUser] (
    [UserGroups_ID] bigint  NOT NULL,
    [EFUsers_ID] bigint  NOT NULL
);
GO

-- Creating table 'EFUserUserRight'
CREATE TABLE [dbo].[EFUserUserRight] (
    [EFUsers_ID] bigint  NOT NULL,
    [UserRights_ID] bigint  NOT NULL
);
GO

-- Creating table 'UserRightUserGroup'
CREATE TABLE [dbo].[UserRightUserGroup] (
    [UserRights_ID] bigint  NOT NULL,
    [UserGroups_ID] bigint  NOT NULL
);
GO

-- Creating table 'EFDynamicDataTypeUserGroupREAD'
CREATE TABLE [dbo].[EFDynamicDataTypeUserGroupREAD] (
    [EFDynamicDataTypesRead_ID] int  NOT NULL,
    [UserGroupsRead_ID] bigint  NOT NULL
);
GO

-- Creating table 'EFDynamicDataTypeUserGroupWRITE'
CREATE TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE] (
    [EFDynamicDataTypesWrite_ID] int  NOT NULL,
    [UserGroupsWrite_ID] bigint  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'EFBaseMenge'
ALTER TABLE [dbo].[EFBaseMenge]
ADD CONSTRAINT [PK_EFBaseMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge'
ALTER TABLE [dbo].[EFCategoryMenge]
ADD CONSTRAINT [PK_EFCategoryMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCountryMenge'
ALTER TABLE [dbo].[EFCountryMenge]
ADD CONSTRAINT [PK_EFCountryMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFDynamicDataTypeMenge'
ALTER TABLE [dbo].[EFDynamicDataTypeMenge]
ADD CONSTRAINT [PK_EFDynamicDataTypeMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFDynamicDataMenge'
ALTER TABLE [dbo].[EFDynamicDataMenge]
ADD CONSTRAINT [PK_EFDynamicDataMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'DynamicDataTypeListEntryMenge'
ALTER TABLE [dbo].[DynamicDataTypeListEntryMenge]
ADD CONSTRAINT [PK_DynamicDataTypeListEntryMenge]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFWorktimeSettingSatz'
ALTER TABLE [dbo].[EFWorktimeSettingSatz]
ADD CONSTRAINT [PK_EFWorktimeSettingSatz]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HolidayDaysSatz'
ALTER TABLE [dbo].[HolidayDaysSatz]
ADD CONSTRAINT [PK_HolidayDaysSatz]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [Id] in table 'EFWorktimeSet'
ALTER TABLE [dbo].[EFWorktimeSet]
ADD CONSTRAINT [PK_EFWorktimeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EFWorktimeProjectSet'
ALTER TABLE [dbo].[EFWorktimeProjectSet]
ADD CONSTRAINT [PK_EFWorktimeProjectSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [ID] in table 'EFBaseMenge_EFPerson'
ALTER TABLE [dbo].[EFBaseMenge_EFPerson]
ADD CONSTRAINT [PK_EFBaseMenge_EFPerson]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFBaseMenge_EFAuthentication'
ALTER TABLE [dbo].[EFBaseMenge_EFAuthentication]
ADD CONSTRAINT [PK_EFBaseMenge_EFAuthentication]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFBaseMenge_EFUser'
ALTER TABLE [dbo].[EFBaseMenge_EFUser]
ADD CONSTRAINT [PK_EFBaseMenge_EFUser]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge_UserCategory'
ALTER TABLE [dbo].[EFCategoryMenge_UserCategory]
ADD CONSTRAINT [PK_EFCategoryMenge_UserCategory]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge_UserGroup'
ALTER TABLE [dbo].[EFCategoryMenge_UserGroup]
ADD CONSTRAINT [PK_EFCategoryMenge_UserGroup]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge_UserRight'
ALTER TABLE [dbo].[EFCategoryMenge_UserRight]
ADD CONSTRAINT [PK_EFCategoryMenge_UserRight]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge_UserTitle'
ALTER TABLE [dbo].[EFCategoryMenge_UserTitle]
ADD CONSTRAINT [PK_EFCategoryMenge_UserTitle]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFBaseMenge_EFAddress'
ALTER TABLE [dbo].[EFBaseMenge_EFAddress]
ADD CONSTRAINT [PK_EFBaseMenge_EFAddress]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFCategoryMenge_DynamicDataTypeCategory'
ALTER TABLE [dbo].[EFCategoryMenge_DynamicDataTypeCategory]
ADD CONSTRAINT [PK_EFCategoryMenge_DynamicDataTypeCategory]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'EFBaseMenge_EFWorktimeEntry'
ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry]
ADD CONSTRAINT [PK_EFBaseMenge_EFWorktimeEntry]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [UserGroups_ID], [EFUsers_ID] in table 'UserGroupEFUser'
ALTER TABLE [dbo].[UserGroupEFUser]
ADD CONSTRAINT [PK_UserGroupEFUser]
    PRIMARY KEY NONCLUSTERED ([UserGroups_ID], [EFUsers_ID] ASC);
GO

-- Creating primary key on [EFUsers_ID], [UserRights_ID] in table 'EFUserUserRight'
ALTER TABLE [dbo].[EFUserUserRight]
ADD CONSTRAINT [PK_EFUserUserRight]
    PRIMARY KEY NONCLUSTERED ([EFUsers_ID], [UserRights_ID] ASC);
GO

-- Creating primary key on [UserRights_ID], [UserGroups_ID] in table 'UserRightUserGroup'
ALTER TABLE [dbo].[UserRightUserGroup]
ADD CONSTRAINT [PK_UserRightUserGroup]
    PRIMARY KEY NONCLUSTERED ([UserRights_ID], [UserGroups_ID] ASC);
GO

-- Creating primary key on [EFDynamicDataTypesRead_ID], [UserGroupsRead_ID] in table 'EFDynamicDataTypeUserGroupREAD'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupREAD]
ADD CONSTRAINT [PK_EFDynamicDataTypeUserGroupREAD]
    PRIMARY KEY NONCLUSTERED ([EFDynamicDataTypesRead_ID], [UserGroupsRead_ID] ASC);
GO

-- Creating primary key on [EFDynamicDataTypesWrite_ID], [UserGroupsWrite_ID] in table 'EFDynamicDataTypeUserGroupWRITE'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE]
ADD CONSTRAINT [PK_EFDynamicDataTypeUserGroupWRITE]
    PRIMARY KEY NONCLUSTERED ([EFDynamicDataTypesWrite_ID], [UserGroupsWrite_ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [UserCategoryID] in table 'EFBaseMenge_EFUser'
ALTER TABLE [dbo].[EFBaseMenge_EFUser]
ADD CONSTRAINT [FK_EFUserUserCategory]
    FOREIGN KEY ([UserCategoryID])
    REFERENCES [dbo].[EFCategoryMenge_UserCategory]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFUserUserCategory'
CREATE INDEX [IX_FK_EFUserUserCategory]
ON [dbo].[EFBaseMenge_EFUser]
    ([UserCategoryID]);
GO

-- Creating foreign key on [UserGroups_ID] in table 'UserGroupEFUser'
ALTER TABLE [dbo].[UserGroupEFUser]
ADD CONSTRAINT [FK_UserGroupEFUser_UserGroup]
    FOREIGN KEY ([UserGroups_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserGroup]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [EFUsers_ID] in table 'UserGroupEFUser'
ALTER TABLE [dbo].[UserGroupEFUser]
ADD CONSTRAINT [FK_UserGroupEFUser_EFUser]
    FOREIGN KEY ([EFUsers_ID])
    REFERENCES [dbo].[EFBaseMenge_EFUser]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserGroupEFUser_EFUser'
CREATE INDEX [IX_FK_UserGroupEFUser_EFUser]
ON [dbo].[UserGroupEFUser]
    ([EFUsers_ID]);
GO

-- Creating foreign key on [EFUsers_ID] in table 'EFUserUserRight'
ALTER TABLE [dbo].[EFUserUserRight]
ADD CONSTRAINT [FK_EFUserUserRight_EFUser]
    FOREIGN KEY ([EFUsers_ID])
    REFERENCES [dbo].[EFBaseMenge_EFUser]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [UserRights_ID] in table 'EFUserUserRight'
ALTER TABLE [dbo].[EFUserUserRight]
ADD CONSTRAINT [FK_EFUserUserRight_UserRight]
    FOREIGN KEY ([UserRights_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserRight]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFUserUserRight_UserRight'
CREATE INDEX [IX_FK_EFUserUserRight_UserRight]
ON [dbo].[EFUserUserRight]
    ([UserRights_ID]);
GO

-- Creating foreign key on [UserRights_ID] in table 'UserRightUserGroup'
ALTER TABLE [dbo].[UserRightUserGroup]
ADD CONSTRAINT [FK_UserRightUserGroup_UserRight]
    FOREIGN KEY ([UserRights_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserRight]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [UserGroups_ID] in table 'UserRightUserGroup'
ALTER TABLE [dbo].[UserRightUserGroup]
ADD CONSTRAINT [FK_UserRightUserGroup_UserGroup]
    FOREIGN KEY ([UserGroups_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserGroup]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserRightUserGroup_UserGroup'
CREATE INDEX [IX_FK_UserRightUserGroup_UserGroup]
ON [dbo].[UserRightUserGroup]
    ([UserGroups_ID]);
GO

-- Creating foreign key on [CreatorID] in table 'EFBaseMenge'
ALTER TABLE [dbo].[EFBaseMenge]
ADD CONSTRAINT [FK_EFBaseEFPerson]
    FOREIGN KEY ([CreatorID])
    REFERENCES [dbo].[EFBaseMenge_EFPerson]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFBaseEFPerson'
CREATE INDEX [IX_FK_EFBaseEFPerson]
ON [dbo].[EFBaseMenge]
    ([CreatorID]);
GO

-- Creating foreign key on [UserTitleID] in table 'EFBaseMenge_EFPerson'
ALTER TABLE [dbo].[EFBaseMenge_EFPerson]
ADD CONSTRAINT [FK_EFPersonUserTitle]
    FOREIGN KEY ([UserTitleID])
    REFERENCES [dbo].[EFCategoryMenge_UserTitle]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFPersonUserTitle'
CREATE INDEX [IX_FK_EFPersonUserTitle]
ON [dbo].[EFBaseMenge_EFPerson]
    ([UserTitleID]);
GO

-- Creating foreign key on [EFPersonID] in table 'EFBaseMenge_EFAddress'
ALTER TABLE [dbo].[EFBaseMenge_EFAddress]
ADD CONSTRAINT [FK_EFPersonEFAddress]
    FOREIGN KEY ([EFPersonID])
    REFERENCES [dbo].[EFBaseMenge_EFPerson]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFPersonEFAddress'
CREATE INDEX [IX_FK_EFPersonEFAddress]
ON [dbo].[EFBaseMenge_EFAddress]
    ([EFPersonID]);
GO

-- Creating foreign key on [EditorID] in table 'EFBaseMenge'
ALTER TABLE [dbo].[EFBaseMenge]
ADD CONSTRAINT [FK_EFBaseEFPerson_Editor]
    FOREIGN KEY ([EditorID])
    REFERENCES [dbo].[EFBaseMenge_EFPerson]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFBaseEFPerson_Editor'
CREATE INDEX [IX_FK_EFBaseEFPerson_Editor]
ON [dbo].[EFBaseMenge]
    ([EditorID]);
GO

-- Creating foreign key on [EFCountryID] in table 'EFBaseMenge_EFAddress'
ALTER TABLE [dbo].[EFBaseMenge_EFAddress]
ADD CONSTRAINT [FK_EFAddressEFCountry]
    FOREIGN KEY ([EFCountryID])
    REFERENCES [dbo].[EFCountryMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFAddressEFCountry'
CREATE INDEX [IX_FK_EFAddressEFCountry]
ON [dbo].[EFBaseMenge_EFAddress]
    ([EFCountryID]);
GO

-- Creating foreign key on [EFDynamicDataTypeID] in table 'EFDynamicDataMenge'
ALTER TABLE [dbo].[EFDynamicDataMenge]
ADD CONSTRAINT [FK_EFDynamicDataEFDynamicDataType]
    FOREIGN KEY ([EFDynamicDataTypeID])
    REFERENCES [dbo].[EFDynamicDataTypeMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFDynamicDataEFDynamicDataType'
CREATE INDEX [IX_FK_EFDynamicDataEFDynamicDataType]
ON [dbo].[EFDynamicDataMenge]
    ([EFDynamicDataTypeID]);
GO

-- Creating foreign key on [CreatorID] in table 'EFDynamicDataTypeMenge'
ALTER TABLE [dbo].[EFDynamicDataTypeMenge]
ADD CONSTRAINT [FK_EFPersonEFDynamicDataTypeCreator]
    FOREIGN KEY ([CreatorID])
    REFERENCES [dbo].[EFBaseMenge_EFPerson]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFPersonEFDynamicDataTypeCreator'
CREATE INDEX [IX_FK_EFPersonEFDynamicDataTypeCreator]
ON [dbo].[EFDynamicDataTypeMenge]
    ([CreatorID]);
GO

-- Creating foreign key on [EFBaseID] in table 'EFDynamicDataMenge'
ALTER TABLE [dbo].[EFDynamicDataMenge]
ADD CONSTRAINT [FK_EFBaseEFDynamicData]
    FOREIGN KEY ([EFBaseID])
    REFERENCES [dbo].[EFBaseMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFBaseEFDynamicData'
CREATE INDEX [IX_FK_EFBaseEFDynamicData]
ON [dbo].[EFDynamicDataMenge]
    ([EFBaseID]);
GO

-- Creating foreign key on [DynamicDataTypeCategoryID] in table 'EFDynamicDataTypeMenge'
ALTER TABLE [dbo].[EFDynamicDataTypeMenge]
ADD CONSTRAINT [FK_DynamicDataTypeCategoryEFDynamicDataType]
    FOREIGN KEY ([DynamicDataTypeCategoryID])
    REFERENCES [dbo].[EFCategoryMenge_DynamicDataTypeCategory]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DynamicDataTypeCategoryEFDynamicDataType'
CREATE INDEX [IX_FK_DynamicDataTypeCategoryEFDynamicDataType]
ON [dbo].[EFDynamicDataTypeMenge]
    ([DynamicDataTypeCategoryID]);
GO

-- Creating foreign key on [EFDynamicDataTypeID] in table 'DynamicDataTypeListEntryMenge'
ALTER TABLE [dbo].[DynamicDataTypeListEntryMenge]
ADD CONSTRAINT [FK_EFDynamicDataTypeDynamicDataTypeListEntry]
    FOREIGN KEY ([EFDynamicDataTypeID])
    REFERENCES [dbo].[EFDynamicDataTypeMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFDynamicDataTypeDynamicDataTypeListEntry'
CREATE INDEX [IX_FK_EFDynamicDataTypeDynamicDataTypeListEntry]
ON [dbo].[DynamicDataTypeListEntryMenge]
    ([EFDynamicDataTypeID]);
GO

-- Creating foreign key on [EFDynamicDataTypesRead_ID] in table 'EFDynamicDataTypeUserGroupREAD'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupREAD]
ADD CONSTRAINT [FK_EFDynamicDataTypeUserGroupREAD_EFDynamicDataType]
    FOREIGN KEY ([EFDynamicDataTypesRead_ID])
    REFERENCES [dbo].[EFDynamicDataTypeMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [UserGroupsRead_ID] in table 'EFDynamicDataTypeUserGroupREAD'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupREAD]
ADD CONSTRAINT [FK_EFDynamicDataTypeUserGroupREAD_UserGroup]
    FOREIGN KEY ([UserGroupsRead_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserGroup]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFDynamicDataTypeUserGroupREAD_UserGroup'
CREATE INDEX [IX_FK_EFDynamicDataTypeUserGroupREAD_UserGroup]
ON [dbo].[EFDynamicDataTypeUserGroupREAD]
    ([UserGroupsRead_ID]);
GO

-- Creating foreign key on [EFDynamicDataTypesWrite_ID] in table 'EFDynamicDataTypeUserGroupWRITE'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE]
ADD CONSTRAINT [FK_EFDynamicDataTypeUserGroupWRITE_EFDynamicDataType]
    FOREIGN KEY ([EFDynamicDataTypesWrite_ID])
    REFERENCES [dbo].[EFDynamicDataTypeMenge]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [UserGroupsWrite_ID] in table 'EFDynamicDataTypeUserGroupWRITE'
ALTER TABLE [dbo].[EFDynamicDataTypeUserGroupWRITE]
ADD CONSTRAINT [FK_EFDynamicDataTypeUserGroupWRITE_UserGroup]
    FOREIGN KEY ([UserGroupsWrite_ID])
    REFERENCES [dbo].[EFCategoryMenge_UserGroup]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFDynamicDataTypeUserGroupWRITE_UserGroup'
CREATE INDEX [IX_FK_EFDynamicDataTypeUserGroupWRITE_UserGroup]
ON [dbo].[EFDynamicDataTypeUserGroupWRITE]
    ([UserGroupsWrite_ID]);
GO

-- Creating foreign key on [EFWorktimeSetting_ID] in table 'HolidayDaysSatz'
ALTER TABLE [dbo].[HolidayDaysSatz]
ADD CONSTRAINT [FK_HolidayDaysEFWorktimeSetting]
    FOREIGN KEY ([EFWorktimeSetting_ID])
    REFERENCES [dbo].[EFWorktimeSettingSatz]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HolidayDaysEFWorktimeSetting'
CREATE INDEX [IX_FK_HolidayDaysEFWorktimeSetting]
ON [dbo].[HolidayDaysSatz]
    ([EFWorktimeSetting_ID]);
GO

-- Creating foreign key on [EFAuthentication_ID] in table 'EFWorktimeSettingSatz'
ALTER TABLE [dbo].[EFWorktimeSettingSatz]
ADD CONSTRAINT [FK_EFAuthenticationEFWorktimeSetting]
    FOREIGN KEY ([EFAuthentication_ID])
    REFERENCES [dbo].[EFBaseMenge_EFAuthentication]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFAuthenticationEFWorktimeSetting'
CREATE INDEX [IX_FK_EFAuthenticationEFWorktimeSetting]
ON [dbo].[EFWorktimeSettingSatz]
    ([EFAuthentication_ID]);
GO

-- Creating foreign key on [EFAuthenticationID] in table 'EFWorktimeSet'
ALTER TABLE [dbo].[EFWorktimeSet]
ADD CONSTRAINT [FK_EFAuthenticationEFWorktime]
    FOREIGN KEY ([EFAuthenticationID])
    REFERENCES [dbo].[EFBaseMenge_EFAuthentication]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFAuthenticationEFWorktime'
CREATE INDEX [IX_FK_EFAuthenticationEFWorktime]
ON [dbo].[EFWorktimeSet]
    ([EFAuthenticationID]);
GO

-- Creating foreign key on [EFWorktimeId] in table 'EFBaseMenge_EFWorktimeEntry'
ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry]
ADD CONSTRAINT [FK_EFWorktimeEFWorktimeEntry]
    FOREIGN KEY ([EFWorktimeId])
    REFERENCES [dbo].[EFWorktimeSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFWorktimeEFWorktimeEntry'
CREATE INDEX [IX_FK_EFWorktimeEFWorktimeEntry]
ON [dbo].[EFBaseMenge_EFWorktimeEntry]
    ([EFWorktimeId]);
GO

-- Creating foreign key on [EFWorktimeSettingID] in table 'EFWorktimeProjectSet'
ALTER TABLE [dbo].[EFWorktimeProjectSet]
ADD CONSTRAINT [FK_EFWorktimeSettingEFWorktimeProject]
    FOREIGN KEY ([EFWorktimeSettingID])
    REFERENCES [dbo].[EFWorktimeSettingSatz]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFWorktimeSettingEFWorktimeProject'
CREATE INDEX [IX_FK_EFWorktimeSettingEFWorktimeProject]
ON [dbo].[EFWorktimeProjectSet]
    ([EFWorktimeSettingID]);
GO

-- Creating foreign key on [EFWorktimeProjectId] in table 'EFBaseMenge_EFWorktimeEntry'
ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry]
ADD CONSTRAINT [FK_EFWorktimeEntryEFWorktimeProject]
    FOREIGN KEY ([EFWorktimeProjectId])
    REFERENCES [dbo].[EFWorktimeProjectSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EFWorktimeEntryEFWorktimeProject'
CREATE INDEX [IX_FK_EFWorktimeEntryEFWorktimeProject]
ON [dbo].[EFBaseMenge_EFWorktimeEntry]
    ([EFWorktimeProjectId]);
GO

-- Creating foreign key on [ID] in table 'EFBaseMenge_EFPerson'
ALTER TABLE [dbo].[EFBaseMenge_EFPerson]
ADD CONSTRAINT [FK_EFPerson_inherits_EFBase]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFBaseMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFBaseMenge_EFAuthentication'
ALTER TABLE [dbo].[EFBaseMenge_EFAuthentication]
ADD CONSTRAINT [FK_EFAuthentication_inherits_EFPerson]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFBaseMenge_EFPerson]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFBaseMenge_EFUser'
ALTER TABLE [dbo].[EFBaseMenge_EFUser]
ADD CONSTRAINT [FK_EFUser_inherits_EFAuthentication]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFBaseMenge_EFAuthentication]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFCategoryMenge_UserCategory'
ALTER TABLE [dbo].[EFCategoryMenge_UserCategory]
ADD CONSTRAINT [FK_UserCategory_inherits_EFCategory]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFCategoryMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFCategoryMenge_UserGroup'
ALTER TABLE [dbo].[EFCategoryMenge_UserGroup]
ADD CONSTRAINT [FK_UserGroup_inherits_EFCategory]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFCategoryMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFCategoryMenge_UserRight'
ALTER TABLE [dbo].[EFCategoryMenge_UserRight]
ADD CONSTRAINT [FK_UserRight_inherits_EFCategory]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFCategoryMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFCategoryMenge_UserTitle'
ALTER TABLE [dbo].[EFCategoryMenge_UserTitle]
ADD CONSTRAINT [FK_UserTitle_inherits_EFCategory]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFCategoryMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFBaseMenge_EFAddress'
ALTER TABLE [dbo].[EFBaseMenge_EFAddress]
ADD CONSTRAINT [FK_EFAddress_inherits_EFBase]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFBaseMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFCategoryMenge_DynamicDataTypeCategory'
ALTER TABLE [dbo].[EFCategoryMenge_DynamicDataTypeCategory]
ADD CONSTRAINT [FK_DynamicDataTypeCategory_inherits_EFCategory]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFCategoryMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ID] in table 'EFBaseMenge_EFWorktimeEntry'
ALTER TABLE [dbo].[EFBaseMenge_EFWorktimeEntry]
ADD CONSTRAINT [FK_EFWorktimeEntry_inherits_EFBase]
    FOREIGN KEY ([ID])
    REFERENCES [dbo].[EFBaseMenge]
        ([ID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------